package com.huobi;

import com.alibaba.fastjson.JSONObject;
import com.huobi.utils.HttpRequestUtil;

import com.huobi.HuobiConst;
import com.rljk.common.consts.HuoBiConst;
import com.tencent.trustsql.sdk.util.HttpClientUtil;
import lombok.extern.slf4j.Slf4j;

import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;

/**
 * Author:   YASUO
 * Date:     2018/8/4 13:24
 * Description:
 */
@Slf4j
public class HuobiTest {

    public static void main(String[] args) throws URISyntaxException {

        String url = "https://api.huobi.pro/";
        String method = "market/tickers";
        //String method = "market/history/kline";
//        String s = HttpRequestUtil.sendGet(url + method+ "?AccessKeyId="+ HuobiConst.accessKey
//                + "&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2017-05-11T15%3A19%3A30",
//                null);
//        log.debug("s:"+s);


//        Map<String,Object> map = new TreeMap<>();
//        map.put("AccessKeyId",HuobiConst.accessKey);
//        map.put("SignatureMethod","HmacSHA256");
//        map.put("SignatureVersion","2");
//        map.put("Timestamp","2017-05-11T15%3A19%3A30");
//        map.put("symbol","btcusdt");
//        map.put("period","1min");
//        map.put("size",50);
//
//        JSONObject postJson = new JSONObject();
//        for (String key : map.keySet()) {
//            postJson.put(key, map.get(key));
//        }




        JSONObject json = new JSONObject();
        json.put("AccessKeyId",HuobiConst.accessKey);
        json.put("SignatureMethod","HmacSHA256");
        json.put("SignatureVersion","2");
        json.put("Timestamp","2017-05-11T15%3A19%3A30");
//        json.put("symbol","btcusdt");
//        json.put("period","1min");
//        json.put("size",50);

        log.debug("postJson:"+json.toJSONString());
        String result = HttpClientUtil.post(url+method, json.toJSONString());
        log.debug("result:"+result);




//        Map<String, Object> params = new TreeMap<>();
//        params.put("AccessKeyId",HuobiConst.accessKey);
//        params.put("SignatureMethod","HmacSHA256");
//        params.put("SignatureVersion","2");
//        params.put("Timestamp","2017-05-11T15%3A19%3A30");
//        String s1 =  HttpRequestUtil.sendGet(url + method, params);
//        log.debug("s1:"+s1);

    }

}
